Skip to content

refactor(protocols)!: range-check the IPv6 extension, MH, HIP and IPv4 makers and adopt the shared helpers (#2614) - #2677

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/2614-internet-helpers
Nov 2, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/2614-internet-helpers

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

What is the purpose of your pull request?

  • refactor — changes neither behaviour nor performance

Description of your pull request and other information

The internet group of #2614, and its last: the HOPOPT, IPv6-Opts, IPv6-Route, MH, HIP and IPv4 makers take the shared value helpers on Protocol.

  • _make_uint checks every integer argument, header and option length, PDM scale and delta, and IPv4 slot count; HIP lifetimes refuse a bool, NaN or infinity.
  • _read_sint/_make_sint carry MH's ANI geo-location degrees, and _decode_signed goes, recorded as versionremoved.
  • pad_length pads all six; _uint_size sizes the HIP Diffie-Hellman and identifier widths, the ILNP nonce and the MH MN-ID.

Breaking: released makers that wrapped a value now raise ProtocolError. A PDM scale past one octet used to warn and now raises, and a bool is refused for a field wider than one bit.

Registry codes, the IPv4 timestamp clamp and fixed-size byte fields are left for #2676. A Sonnet cross-review re-derived the sweep, PDM, the HIP lifetimes and byte-identical parsing; the two changes it asked for are in this head.

Closes #2614

…4 makers and adopt the shared helpers (#2614)

- _make_uint: every integer argument of the MH message, option and
  sub-option makers and of the HIP parameter makers, HIP.make's header
  fields, and the HOPOPT, IPv6-Opts, IPv4 and IPv6-Route option and header
  fields refuse a negative, too wide or bool value instead of wrapping it.
- _make_uint: the HOPOPT and IPv6-Opts Hdr Ext Len, the IPv4 IHL and the MH
  and HIP header lengths refuse a header too long for the field.
- _make_uint: the PDM scales and deltas, the option makers' registry codes,
  the one-octet lengths of every MH option and the LIO, SMF_DPD and
  unassigned IPv6 options, the IPv4 slot counts, timestamp slots and
  security authorities, and HIP's RHASH_len; the HIP lifetimes refuse a
  bool, NaN or infinity.
- _read_sint/_make_sint: MH's ANI geo-location degrees; _decode_signed goes,
  recorded as versionremoved.
- pad_length: IPv4, HOPOPT, IPv6-Opts, IPv6-Route, MH and HIP padding.
- _uint_size: HIP Diffie-Hellman and identifier widths, the ILNP nonce and
  the MH MN-ID.
- Breaking: released makers that wrapped now raise ProtocolError, a PDM
  scale past one octet included, where it warned; a bool is refused for a
  field wider than one bit.
- Tests: MH and HIP sweep tables, option registry codes and MH option
  lengths checked against the maker signatures; every refusal fails on
  main; field maxima build and round-trip.
@JarryShaw JarryShaw added this to the PyPCAPKit v1.6 milestone Nov 2, 2026
@JarryShaw JarryShaw added breaking Breaks public-facing behaviour or API (apply alongside the type label) refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: good-to-go Cross-review at the current head says ready; CI state is separate labels Nov 2, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 3e8b65665. A Sonnet cross-review re-derived the range sweep, PDM, the HIP lifetimes and byte-identical parsing. Both changes it asked for are in this head: the unassigned options' Opt Data Len check, and the registry-code clause in the IPv4 and IPv6-Route versionchanged notes. I checked that delta myself. Registry codes, the timestamp clamp and fixed-size byte fields are #2676.

@JarryShaw JarryShaw moved this to In review in PyPCAPKit Nov 2, 2026
@JarryShaw
JarryShaw merged commit cf979c3 into main Nov 2, 2026
62 checks passed
@JarryShaw
JarryShaw deleted the refactor/2614-internet-helpers branch November 2, 2026 19:26
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Nov 2, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Nov 2, 2026
JarryShaw added a commit that referenced this pull request Nov 2, 2026
…TTP/2 and SCTP rebuilds into 1.6.0 (#2449)

- Breaking: the IPv4, HOPOPT, IPv6-Opts, IPv6-Route, MH and HIP makers
  (#2677) raise on a value a field cannot hold, where 1.5.x wrote it
  masked; a PDM scale past one octet raises where it warned, and
  MH._decode_signed is removed. The entry gives the old and new values.
- Fixed: an SCTP packet cut short of its declared length rebuilds as
  captured (#2679).
- Folded into unreleased entries: a cut HTTP/2 frame after the connection
  preface rebuilds, into the cut-SETTINGS entry (#2675); IPv4's Quick-Start
  function and not-used octet refusals, into the Quick-Start entry (#2677).
- No entry for the test-only 42a6133.
- CHANGELOG.md regenerated; util/changelog_md.py --check passes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaks public-facing behaviour or API (apply alongside the type label) refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

refactor(protocols): move shared value pack/unpack helpers into the Protocol utilities

1 participant